package com.test.rabbitma.test.work;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.test.rabbitma.test.util.ConnectionUtil;

public class Send
{

	private final static String QUEUE_NAME = "test_queue_work";

	public static void main(String[] argv) throws Exception
	{
		// 获取到连接以及mq通道
		Connection connection = ConnectionUtil.getConnection();
		Channel channel = connection.createChannel();

		// 声明队列
		channel.queueDeclare(QUEUE_NAME, false, false, false, null);

		for (int i = 0; i < 100; i++)
		{
			// 消息内容
			String message = "" + i;
			channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
			System.out.println(" [x] Sent '" + message + "'");

			Thread.sleep(i * 10);
		}

		channel.close();
		connection.close();
	}
}